package common;

import util.ActConf;
import util.remote.RemoteConnectResult;

/**
 * 数据分析器的父类
 *
 * @see #result 连接结果 包含可用的redis工具和mysql连接工具
 * @see #actConf 活动配置
 * <p>
 * Created by J.Chen on 2017/5/22.
 */
public abstract class DataAnalysis {
    protected RemoteConnectResult result;
    protected ActConf actConf;

    public DataAnalysis(RemoteConnectResult result, String confCode) {
        this.result = result;
        this.actConf = new ActConf().initConf(result.getRemoteConf(), result.getMysqlUtil(), confCode);
    }

    public boolean isTimeEnd() {
        return actConf == null || actConf.getConf() == null || ( actConf.getTimeEnd() != null && actConf.getTimeEnd().getTime() <= System.currentTimeMillis());
    }

    public abstract void execute();

    protected String getStrTimeStart() {
        return this.actConf.getActTimeStartStr();
    }
}
